import platform
import os

import core

def get_data_dir() -> str:
    safe_config()
    if platform.system().lower() == "windows":
        appdata = os.getenv("APPDATA")
        return os.path.join(appdata,"pyfuse")
    else:
        return os.path.realpath("~/pyfuse/")
    
def get_config_path() -> str:
    safe_config()
    return os.path.join(get_data_dir(),"config.json")

def get_packages_path() -> str:
    safe_config()
    return os.path.join(get_data_dir(),"packages")

def get_environments_path() -> str:
    safe_config()
    return os.path.join(get_data_dir(),"environments")

@core.once
def safe_config() -> None:
    os.makedirs(get_data_dir(), exist_ok=True)
    os.makedirs(get_packages_path(), exist_ok=True)
    os.makedirs(get_environments_path(), exist_ok=True)